import { createRouter, createWebHistory } from 'vue-router';

const router = createRouter({
  history: createWebHistory(),
  // 路由的配置规范：请求与页面的对应关系
  routes: [
    {
      path: '/',
      redirect: '/login',
    },
    {
      path: '/login',
      component: () => import('@/views/Login.vue'),
    },
    {
      path: '/index',
      component: () => import('@/views/Index.vue'),
      children: [
        {
          path: '/bed/bedMap',
          component: () => import('@/views/bed/BedMap.vue'),
        },
        {
          path: '/bed/bedManage',
          component: () => import('@/views/bed/BedManage.vue'),
        },
        {
          path: '/customer/checkIn',
          component: ()=>import('@/views/customer/CheckIn.vue')
        },
        {
          path: '/health/serviceCustomerSetting',
          component: ()=>import('@/views/health/serviceCustomerSetting.vue')
        },
        {
          path: '/customer/checkOut',
          component: ()=>import('@/views/customer/checkOut.vue')
        },
        {
          path: '/customer/outRecords',
          component: ()=>import('@/views/customer/outRecords.vue')
        },
        {
          path: '/customer/preference',
          component: ()=>import('@/views/customer/preference.vue')
        },
        {
          path: '/nurse/nurseLevel',
          component: ()=>import('@/views/nurse/nurseLevel.vue')
        },
        {
          path: '/nurse/nurseItem',
          component: ()=>import('@/views/nurse/nurseItem.vue')
        },
        {
          path: '/nurse/nurseSetting',
          component: ()=>import('@/views/nurse/nurseSetting.vue')
        },
        {
          path: '/nurse/nurseRecords',
          component: ()=>import('@/views/nurse/nurseRecords.vue')
        }
      ],
    },
  ],
});

// 路由守卫
// router.beforeEach((to, from, next) => {
//   // 判断用户是否登录，主要判断token是否存在
//   let token = sessionStorage.getItem('token');
//   if (to.path !== '/login' && to.path !== '/register') {
//     if (token == null || token === '') {
//       next('/login');
//     }
//   }
//   // 放行
//   next();
// });

export default router;
